<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="box">
        <div class="bg">
            <div class="top"></div>
            <div class="bottom"></div>
        </div>
        <ul>
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
        </ul>
    </div>

</body>
<script>
    let ulBox = document.querySelector('ul')
    ulBox.addEventListener('click',function(e){
        e.target.style.backgroundColor = '#fff'
        let allLi = e.target.parentElement.children
        let index = [...allLi].indexOf(e.target)
        // if(index === 0){

        // }
        e.target.style.borderRadius = '10px'
        if(index -1 >= 0){
            allLi[index-1].style.borderBottomRightRadius = '10px'
        }
        if(index + 1 <= allLi.length -1){
            allLi[index+1].style.borderBottomLeftRadius = '10px'
        }
    })
</script>
<style>
    *{
        padding: 0;
        margin: 0;
    }
    ul{
        left: 0;
        top: 0;
        position: absolute;
        z-index: 10;
        overflow: hidden;
        /* background-color: #ccc; */
    }
    li{
        list-style: none;
        float: left;
        padding: 10px 20px;
        /* border-radius: 10px; */
        background-color: #ccc;
    }
    .box{
        position: relative;
    }
    .bg{
        left: 0;
        top: 0;
        position: absolute;
        height: 40px;
        float: left;
        width: 100%;
    }
    .top{
        height: 50%;
        background-color: #ccc;
    }
    .bottom{
        height: 50%;
        background-color: #fff;
    }
</style>
</html>